package cn.bdqn.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.bdqn.dao.CommentMapper;
import cn.bdqn.dao.ComplaintsMapper;
import cn.bdqn.entity.Complaints;
import cn.bdqn.entity.UsersAndComVo;
import cn.bdqn.util.Page;
@Service("complaintsService")
public class ComplaintsServiceImpl implements ComplaintsService {
	@Autowired
	private ComplaintsMapper complaintsMapper;
	@Autowired
	private CommentMapper commentMapper;
	@Override
	public void queryAllComplaints(String context, Page<UsersAndComVo> page) {
		Integer count=complaintsMapper.queryComplaintsCount(context);
		System.out.println("数量："+count);
		page.setTotalCount(count);
		List<UsersAndComVo> list=complaintsMapper.queryAllComplaints(context, page.getStart(), page.getPageSize());
		page.setList(list);
		
	}

	@Override
	public Integer saveComplaints(Complaints complaints) {
		return complaintsMapper.saveComplaints(complaints);
	}

	@Override
	public UsersAndComVo queryComplaintsbyComplaintsid(Integer complaintsid) {
		return complaintsMapper.queryComplaintsbyComplaintsid(complaintsid);
	}

	@Override
	public Integer deleteComplaints(Integer complaintsid) {
		commentMapper.deletecommentByComplaintsid(complaintsid);
		return complaintsMapper.deleteComplaints(complaintsid);
	}

	

}
